Add a boolean ::displace-focus style property and apply child displacement
authorMatthias Clasen <mclasen@redhat.com>
Mon, 20 Sep 2004 14:43:18 +0000 (14:43 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 20 Sep 2004 14:43:18 +0000 (14:43 +0000)
2004-09-20  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus
style property and apply child displacement to the focus rectangle
if it is TRUE.  (#141170, Soeren Sandmann)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkbutton.c

index d23d7ae0c9af1d39a67bb52b71b0b6bf92e71d89..8f40d4897e7bf97a659b76588e53bb0b62f33b6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus
+       style property and apply child displacement to the focus rectangle 
+       if it is TRUE.  (#141170, Soeren Sandmann)
+
 Sun Sep 19 23:56:18 2004  Søren Sandmann  <sandmann@redhat.com>
 
        * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to
index d23d7ae0c9af1d39a67bb52b71b0b6bf92e71d89..8f40d4897e7bf97a659b76588e53bb0b62f33b6f 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus
+       style property and apply child displacement to the focus rectangle 
+       if it is TRUE.  (#141170, Soeren Sandmann)
+
 Sun Sep 19 23:56:18 2004  Søren Sandmann  <sandmann@redhat.com>
 
        * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to
index d23d7ae0c9af1d39a67bb52b71b0b6bf92e71d89..8f40d4897e7bf97a659b76588e53bb0b62f33b6f 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus
+       style property and apply child displacement to the focus rectangle 
+       if it is TRUE.  (#141170, Soeren Sandmann)
+
 Sun Sep 19 23:56:18 2004  Søren Sandmann  <sandmann@redhat.com>
 
        * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to
index d23d7ae0c9af1d39a67bb52b71b0b6bf92e71d89..8f40d4897e7bf97a659b76588e53bb0b62f33b6f 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus
+       style property and apply child displacement to the focus rectangle 
+       if it is TRUE.  (#141170, Soeren Sandmann)
+
 Sun Sep 19 23:56:18 2004  Søren Sandmann  <sandmann@redhat.com>
 
        * gtk/gtkmenu.c (MENU_SCROLL_TIMEOUT2): Change from 50 to 20 to
index d2ed6012500d424104399cd84d7b25e57ee83770..bcce7513495727c5ea1b2177a3b8a065ea06a40d 100644 (file)
@@ -376,6 +376,21 @@ gtk_button_class_init (GtkButtonClass *klass)
                                                             0,
                                                             G_PARAM_READABLE));
 
+  /**
+   * GtkButton:displace-focus:
+   *
+   * Whether the child_displacement_x/child_displacement_y properties should also 
+   * affect the focus rectangle.
+   *
+   * Since: 2.6
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_boolean ("displace-focus",
+                                                                P_("Displace focus"),
+                                                                P_("Whether the child_displacement_x/_y properties should also affect the focus rectangle"),
+                                                      FALSE,
+                                                      G_PARAM_READABLE));
+
   gtk_settings_install_property (g_param_spec_boolean ("gtk-button-images",
                                                       P_("Show button images"),
                                                       P_("Whether stock icons should be shown in buttons"),
@@ -1064,6 +1079,16 @@ _gtk_button_paint (GtkButton    *button,
        
       if (GTK_WIDGET_HAS_FOCUS (widget))
        {
+         gint child_displacement_x;
+         gint child_displacement_y;
+         gboolean displace_focus;
+         
+         gtk_widget_style_get (GTK_WIDGET (widget),
+                               "child_displacement_y", &child_displacement_y,
+                               "child_displacement_x", &child_displacement_x,
+                               "displace_focus", &displace_focus,
+                               NULL);
+
          if (interior_focus)
            {
              x += widget->style->xthickness + focus_pad;
@@ -1079,6 +1104,12 @@ _gtk_button_paint (GtkButton    *button,
              height += 2 * (focus_width + focus_pad);
            }
 
+         if (button->depressed && displace_focus)
+           {
+             x += child_displacement_x;
+             y += child_displacement_y;
+           }
+
          gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
                           area, widget, "button",
                           x, y, width, height);